#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   1B.py
@Time    :   2020/06/24 13:23:49
@Author  :   Malygos_l 
@Version :   1.0
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''
# Start typing your code from here
'''
1  有100个同学的分数：数据请用随机函数生成；
    B 利用线程池来实现；
'''


from concurrent.futures import ThreadPoolExecutor
import random
import threading
import time


i = 1
mutex = threading.Lock()


def randgrade():
    global i
    x = 0
    for x in range(20):
        mutex.acquire()  #上锁
        grade = random.randint(60, 100)
        print("%d\t%d" % (i, grade))
        i += 1
        time.sleep(1)
        mutex.release()  #解锁

def main():
    TPE = ThreadPoolExecutor(max_workers=5)
    for x in range(5):
        TPE.submit(randgrade)
    TPE.shutdown


if __name__ == "__main__":
    main()
